package com.lanou.beautifulwardrobe.activity_zhuti.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.lanou.beautifulwardrobe.entify.WelfareData;
import com.lanou.beautifulwardrobe.factory.ActivityFragmentFactory;

import java.util.List;

/**
 * Created by dllo on 15/10/21.
 */
public class ActivityViewPagerAdapter extends FragmentPagerAdapter {
    private List<WelfareData> datas;

    public void addData(List<WelfareData> items) {
        datas = items;
        notifyDataSetChanged();
    }

    public ActivityViewPagerAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int position) {
        //   Log.i("lanou", position + "#####");
        //return HomeFragment.getHomeFragment(position);
       String id= datas.get(position).getActivity_category_ids();

        return ActivityFragmentFactory.createFragment(position, id);
    }

    @Override
    public int getCount() {

        return datas != null && datas.size() > 0 ? datas.size() : 0;
        // return titles.length;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        //  Log.i("lanou",position+"======");
        return datas != null && datas.size() > 0 ? datas.get(position).getCategory_title() : "无";
        // return titles[position];
    }
}

